<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function sidEffecting(ary) {
            console.log(ary);
            ary[0] = ary[2];
        }
        function bar(a, b, c) {
            c = 10;
            sidEffecting(arguments);
            return a + b + c;
        }
        const a1 = bar(1, 1, 1)
        console.log(a1);



        const task = [];
        const output = (i) => new Promise(function (resolve, reject) {
            setTimeout(function () {
                console.log(i);
                resolve();
            }, i * 1000)
        })
        for (var i = 0; i < 5; i++) {
            task.push(output(i));
        }

        Promise.all(task).then(() => {
            setTimeout(() => {
                console.log(i);
            }, 5000)
        }
        )

    </script>
</body>

</html>